package ability2898

import (
    "log"
    "errors"
    "topsdk"
    "topsdk/ability2898/request"
    "topsdk/ability2898/response"
    "topsdk/util"
)

type Ability2898 struct {
    Client *topsdk.TopClient
}

func NewAbility2898(client *topsdk.TopClient) *Ability2898{
    return &Ability2898{client}
}

/*
    商家完成小程序相关配置
*/
func (ability *Ability2898) TaobaoMiniappAppSellerConfigComplete(req *request.TaobaoMiniappAppSellerConfigCompleteRequest,session string) (*response.TaobaoMiniappAppSellerConfigCompleteResponse,error) {
    if(ability.Client == nil) {
        return nil,errors.New("Ability2898 topClient is nil")
    }
    var jsonStr,err = ability.Client.ExecuteWithSession("taobao.miniapp.app.seller.config.complete",req.ToMap(),req.ToFileMap(),session)
    var respStruct = response.TaobaoMiniappAppSellerConfigCompleteResponse{}
    if(err != nil){
        log.Println("taobaoMiniappAppSellerConfigComplete error",err)
        return &respStruct,err
    }
    err = util.HandleJsonResponse(jsonStr, &respStruct)
    if(respStruct.Body == "" || len(respStruct.Body) == 0) {
        respStruct.Body = jsonStr
    }
    return &respStruct,err
}
